package com.shenmazong.thread;

/**
 * @program: server-java-demo
 * @description: ThreadMethod2
 * @author: 亮子说编程
 * @create: 2020-10-14 20:24
 **/


class ThreadRunnable implements Runnable {

    public void run() {
        for (int i = 0; i < 20; i++) {
            System.out.println("i="+i);
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

public class ThreadMethod2 {

    public static void main(String[] args) {

        //--1 创建线程
        Thread thread = new Thread(new ThreadRunnable());

        //--2 运行线程
        thread.start();
    }
}
